public class SimpleGenericExample3 {

  public static void main(String[] args) {

    new SimpleGeneric<A>(new A()).test();
    new SimpleGeneric<B>(new B()).test();
    new SimpleGeneric<C>(new C()).test();
  }
}


class SimpleGeneric<T extends A> {

  private T object;

  public SimpleGeneric(T object) {
    this.object = object;
  }

  public void test() {
    this.object.printClass();
  }
}


class A {

  public void printClass() {
    System.out.println("I am in super class A");
  }
}


class B extends A {

  public void printClass() {
    System.out.println("I am in sub class B");
  }
}


class C extends A {

  public void printClass() {
    System.out.println("I am in sub class C");
  }
}
